import request from '@/config/axios'
// 规则表实例
export interface RuleVO {
  id: number
  remark: string
  ruleName: string
  labelname: string
  labelid: number
  tamplateid: string
}
// 标签表实例
export interface LabelVO {
  id: number
  labelid: string
  labelname: string
  fatherid: string

  // 父标签名称
  fathername: string
  // 模版标识
  tamplateid: string
  //排序
  sort: string
  //路径
  path: string
  //是否为拆分
  split: string
}
export interface LabelTreeVo {
  nameList: string
  labelname: string
}
export interface MergeLabel {
  tamplateY: string
  tamplateE: string
  labelY: number
  labelE: number
  newtamplateid: string
  newtamplatename: string
}

export interface SplitLabel {
  labelId: string
  tamplateid: string
  newtamplateid: string
  newtamplatename: string
}
// 查询规则管理列表
export const getRulePage = (params: any) => {
  return request.get({ url: '/system/rule/page', params })
}

// 查询规则详情
export const getRule = (id: number) => {
  return request.get({ url: '/system/rule/getRule?id=' + id })
}
// 智能推荐
export const zhinengtuijian = (id: number) => {
  return request.get({ url: '/system/ckm/recommendation?labelid=' + id })
}
// 新增规则
export const createRule = (data: RuleVO) => {
  return request.post({ url: '/system/rule/createRule', data })
}

// 修改规则
export const updateRule = (data: RuleVO) => {
  return request.put({ url: '/system/rule/updateRule', data })
}

// 删除规则
export const deleteRule = (id: number) => {
  return request.delete({ url: '/system/rule/deleteRule?id=' + id })
}
// 批量删除规则
export const deleteRuleList = (ids: Array<number>) => {
  return request.delete({ url: '/system/rule/deleteRuleByIds?ids=' + ids })
}

// 获取标签列表
export const BiaoQianTree = (data: LabelTreeVo) => {
  return request.post({ url: '/system/label/tree', data })
}
// 在标签合并页面 获取标签树形结构(后端生成)
export const getBiaoQianTree = (data: LabelTreeVo) => {
  return request.post({ url: '/system/label/getBiaoQianTree', data })
}
// 获取标签一级模版名称集合
export const selectTreeName = () => {
  return request.post({ url: '/system/label/selectTreeName' })
}
export const getLabelFatherById = (id: number) => {
  return request.get({ url: '/system/label/getLabelFatherById?id=' + id })
}
// 新增标签
export const createLabel = (data: LabelVO) => {
  return request.post({ url: '/system/label/addLabel', data })
}
export const updateLabel = (data: LabelVO) => {
  return request.post({ url: '/system/label/updateLabel', data })
}
export const getLabelById = (id: number) => {
  return request.get({ url: '/system/label/getLabelById?id=' + id })
}

// 查看当前标签是否有子节点
export const labelIsExists = (id: number) => {
  return request.get({ url: '/system/label/labelIsExists?id=' + id })
}
export const delLabel = (id: number) => {
  return request.get({ url: '/system/label/delLabel?id=' + id })
}
// 标签合并
export const mergeLabel = (data: MergeLabel) => {
  return request.post({ url: '/system/label/mergeLabel', data })
}

// 标签拆分
export const splitLabel = (data: SplitLabel) => {
  return request.post({ url: '/system/label/splitLabel', data })
}
